//
// Created by icezhang on 2021/9/8.
//

#include "MysqlSingleton.h"

string  MysqlSingleton::doSomething() {

    if(mysql_query(con, "show databases;"))
    {
        fprintf(stderr, "%s\n", mysql_error(con));
        mysql_close(con);
        exit(EXIT_FAILURE);
    }


    res=mysql_store_result(con);
    num_fields= mysql_num_fields(res);
    field=mysql_fetch_fields(res);
    while (row = mysql_fetch_row(res)) //获取整条数据内容
    {
        for(i=0;i<num_fields;++i)
        {
            printf("[%s]=>[%s]\n",field[i].name,row[i]);
        }
    }
    mysql_free_result(res);
    puts("mariadb is connect and run succesed!");
    return "ok";
}

